<?php
/**
* $Id: edit_userinfo.php 138 2010-05-01 03:37:42Z bwanglei $
*/

include_once(dirname(__FILE__).'/init.php');

if ($_SERVER['REQUEST_METHOD']=='POST') {
	$username = $_POST['username'];
	$nickname = $_POST['nickname'];
	$email = $_POST['email'];
	$password = $_POST['password'];

	if ($password=='') {
		$query = 'update `apf_user` set `nickname`="'.$nickname.'", `email`="'.$email.'" where `username`="'.$username.'"';
		$mysql_conn->query($query);
	} else {
		$password = md5($password);
		$query = 'update `apf_user` set `nickname`="'.$nickname.'", `email`="'.$email.'", `password`="'.$password.'" where `username`="'.$username.'"';
		$mysql_conn->query($query);
	}

	if ($mysql_conn->affected_rows!=1) {
		apf_msg('修改不成功!',apf_full_url());
		die();
	} else {
		// 修改之后更新 COOKIE
		$user_data = apf_get_user($username,$mysql_conn);
		apf_set_login($user_data);

		apf_msg('修改成功',apf_full_url());
		die();
	}
}
include_once(TEMP_ROOT_PATH.'/edit_userinfo.php');
?>
